<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <title>Title</title>
  <!-- 引入 ECharts 和 jQuery -->
  <script src="https://cdn.bootcdn.net/ajax/libs/echarts/5.4.2/echarts.min.js"></script>
  <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
</head>
<body>
<div id="main" style="width: 600px;height:400px;"></div>
</body>
<script>
  // data 的结构:
  // {
  //     candidates: ["张三","李四","王五"],
  //     values: [5, 20, 36]
  // }
  // 基于准备好的dom，初始化echarts实例
  var myChart = echarts.init(document.getElementById('main'));
  $.get('vote/votelist').done(function(data) {
    myChart.setOption({
      title: {
        text: '候选人投票结果'
      },
      tooltip: {},
      legend: {},
      xAxis: {
        data: data.candidates
      },
      yAxis: {},
      series: [
        {
          name: '票数',
          type: 'bar',
          data: data.values
        }
      ]
    });
  });
</script>
</html>